package util.encrypt.apache_commons;

import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import org.apache.commons.codec.binary.Base64;
import util.encrypt.CriptoTripleDESBasico;

/**
 * Algoritmo triple DES, con clave MD5, modo ECB por defecto y codificacion Base64
 * @author Rdelacruz
 */
public class CriptoTripleDES 
extends CriptoTripleDESBasico
{

    public CriptoTripleDES(String key) 
            throws NoSuchAlgorithmException, UnsupportedEncodingException, 
            NoSuchPaddingException, InvalidKeyException, 
            InvalidAlgorithmParameterException {
        super(key);
    }

    public String encrypt(String data) 
            throws NoSuchAlgorithmException, NoSuchPaddingException, 
            InvalidKeyException, UnsupportedEncodingException, 
            BadPaddingException, IllegalBlockSizeException {        
    	return Base64.encodeBase64String(encryptToBytes(data));
    }
    
    public String decrypt(String data) 
            throws UnsupportedEncodingException, IllegalBlockSizeException, 
            BadPaddingException {                
        return decrypt(Base64.decodeBase64(data));
    }
}
